package com.yang.Offer;

public class Offer06 {
}

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) { val = x; }
 * }
 */
class SolutionOffer06 {
    public int[] reversePrint(ListNode head) {
        if (head == null){
            return new int[0];
        }
        ListNode dumy = head;
        int count = 0;
        while(dumy != null){
            dumy = dumy.next;
            count ++;
        }
        int[] nums = new int[count];
        count = count - 1;
        while( head != null)
        {
            nums[count--] = head.val;
            head = head.next;
        }
        return nums;
    }
    public static class ListNode {
        int val;
        ListNode next;
        ListNode(int x) { val = x; }
    }
}
